home *** CD-ROM | disk | FTP | other *** search
- /* drvr.c
- This is the Unit Table dcmd.
-
- Copyright © 1988 Apple Computer, Inc. All rights reserved.
-
- Modification history:
- 7Dec88 sad show driver version
- 29Nov88 sad revised for new dcmd names
- 13Oct88 sad written from file.c
-
- The following MPW commands will build the dcmd and copy it to the
- "Debugger Prefs" file in the System folder. The dcmd's name in
- MacsBug will be the name of the file built by the Linker.
- You must first copy dcmd.h, dcmdGlue.a.o and DRunTime.o from the
- C Samples folder into this folder.
-
- C Put.c
- C Drvr.c
- Link dcmdGlue.a.o Drvr.c.o put.c.o DRuntime.o "{Libraries}"Interface.o -o Drvr
- BuildDcmd Drvr 1000
- Echo 'include "Drvr";' | Rez -a -o "{systemFolder}Debugger Prefs"
- */
-
- #ifdef USESTDIO
- #include <stdio.h>
- #endif
-
- #include <Types.h>
- #include <Memory.h>
- #include <Devices.h>
- #include <SysEqu.h>
-
- #include "dcmd.h"
- #include "put.h"
-
-
- typedef struct DRVR
- {
- short drvrFlags;
- short drvrDelay;
- short drvrEMask;
- short drvrMenu;
- short drvrOpen;
- short drvrPrime;
- short drvrCtl;
- short drvrStatus;
- short drvrClose;
- Str255 drvrName;
- } DRVR;
-
-
- static void DrawHdr()
- {
- // 1 2 3 4 5 6 7
- // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
- dcmdDrawLine("\pdRef dNum Driver Flg Ver qHead Storage Window Dely Drvr at DCE at");
- }
-
-
- static void DrawDCE(int dref, AuxDCE* dcep)
- {
- DRVR* drvrp;
-
- PutUHexWord(dref);
- PutSpace();
- PutUHexWord(~dref);
- PutSpace();
- if (dcep->dCtlFlags & 0x40)
- {
- if (dcep->dCtlDriver)
- {
- drvrp = *(DRVR**)dcep->dCtlDriver;
- if (drvrp) PutPStrTruncTo(drvrp->drvrName,21);
- else PutPStrTruncTo("\p-purged-",21);
- }
- else
- {
- PutPStrTruncTo("\p",21);
- };
- }
- else
- {
- if (dcep->dCtlDriver)
- {
- drvrp = (DRVR*)dcep->dCtlDriver;
- PutPStrTruncTo(drvrp->drvrName,21);
- }
- else
- {
- PutPStrTruncTo("\p",21);
- };
- };
- PutSpace();
- PutChar((dcep->dCtlFlags & 0x80) ? 'B' : 'b');
- PutChar((dcep->dCtlFlags & 0x40) ? 'H' : 'P');
- PutChar((dcep->dCtlFlags & 0x20) ? 'O' : 'C');
- PutSpace();
- PutUDecTo((unsigned char)dcep->dCtlQHdr.qFlags,30);
- PutSpace();
- PutUHexZTo((unsigned long)dcep->dCtlQHdr.qHead,6,36);
- PutSpace();
- PutUHexZTo((unsigned long)dcep->dCtlStorage,6,44);
- PutSpace();
- PutUHexZTo((unsigned long)dcep->dCtlWindow,6,51);
- PutSpace();
- PutUHexWord((unsigned long)dcep->dCtlDelay);
- PutSpace();
- PutUHexZTo((unsigned long)drvrp,6,65);
- PutSpace();
- PutUHexZTo((unsigned long)dcep,6,72);
- PutLine();
- if (dref != dcep->dCtlRefNum)
- {
- // this case actually happens normally for drvr fffe .Sony for the HD20 (pre-SCSI)
- PutPStr("\p that is strange: dCtlRefNum = ");
- PutUHexWord(dcep->dCtlRefNum);
- PutLine();
- }
- } // DrawDCE
-
- // EJECT
-
- pascal void CommandEntry(dcmdBlock* paramPtr)
- {
- switch (paramPtr->request)
- {
- case dcmdInit:
- break;
-
- case dcmdHelp:
- dcmdDrawLine("\pdrvr [refnum|num]");
- dcmdDrawLine("\p Displays driver information for the given refnum or all installed drivers.");
- dcmdDrawLine("\p Flags are B/b=Busy, H/P=Handle/Ptr, O/C=Open/Closed.");
- break;
-
- case dcmdDoIt:
- {
- Boolean doOne = false;
- long dref;
- int numdces;
-
- dcmdSwapWorlds();
-
- dcmdDrawLine("\pDisplaying Driver Control Entries");
-
- // get low-memory values after dcmdSwapWorlds()
- numdces = *(unsigned short *)UnitNtryCnt;
-
- (void)dcmdGetNextExpression(&dref, &doOne);
-
- if (doOne)
- {
- int dnum;
- dref = (short)dref;
- if (dref < 0) dnum = ~dref;
- else
- {
- dnum = dref;
- dref = ~dref;
- }
- if (dnum > numdces)
- {
- #ifdef USESTDIO
- Str255 line;
- sprintf(line,"bad refnum 0x%.4x",(unsigned short)dref);
- dcmdDrawLine((Str255)c2pstr(&line));
- #else
- PutPStr("\pbad refnum ");
- PutUHexWord(dref);
- PutSpace();
- PutUHexWord(~dref);
- PutLine();
- #endif
- }
- else
- {
- AuxDCE** dceh = (*(AuxDCE****)UTableBase)[dnum];
- if (dceh)
- {
- DrawHdr();
- DrawDCE(dref,*dceh);
- }
- else
- {
- PutPStr("\pDriver ");
- PutUHexWord(dref);
- PutSpace();
- PutUHexWord(~dref);
- PutPStr("\p is not in installed");
- PutLine();
- }
- }
- }
- else
- {
- int dcesused = 0;
- int dnum;
- AuxDCE*** dcehp;
- Boolean foundOne = false;
- for (dnum = 0, dcehp = *(AuxDCE****)UTableBase;
- dnum < numdces;
- dnum++, dcehp++)
- {
- if (*dcehp)
- {
- dcesused++;
- if (!foundOne)
- {
- DrawHdr();
- foundOne = true;
- }
- DrawDCE(~dnum,**dcehp);
- }
- if (paramPtr->aborted) break;
- }
- if (!paramPtr->aborted)
- {
- PutUDec(numdces);
- PutPStr("\p Unit Table entries, ");
- PutUDec(dcesused);
- PutPStr("\p in use, ");
- PutUDec(numdces - dcesused);
- PutPStr("\p free");
- PutLine();
- }
- }
-
- dcmdSwapWorlds();
- }
- break;
-
- default:
- PutPStr("\punknown request ");
- PutUDec(paramPtr->request);
- PutLine();
- break;
- }
- } // CommandEntry
-